/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wisp.dataObjects;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.Vector;
import java.util.StringTokenizer;
import java.lang.Exception.*;
/**
 *
 * @author Shelley Chuateco Co
 */
public class CharLevel {
     private dbConnection dbcon = new dbConnection();
     private int id, expPt;
     
     public void viewExp (int i){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
                
        getDbcon().connect();
        query = "SELECT * FROM CharLevel WHERE id = ?";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setInt(1, i);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {
                this.setExpPt(rs.getInt("expPt"));
                this.setId(rs.getInt("id"));
            }
            rs.close(); 					
            stmt.close();
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
 
        }
    }
     
     public void viewLevel (int i){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
                
        getDbcon().connect();
        query = "SELECT * FROM CharLevel WHERE expPt < ?";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setInt(1, i);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {
                this.setExpPt(rs.getInt("expPt"));
                this.setId(rs.getInt("id")-1);
            }
            rs.close(); 					
            stmt.close();
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
 
        }
    }

    public dbConnection getDbcon() {
        return dbcon;
    }

    public void setDbcon(dbConnection dbcon) {
        this.dbcon = dbcon;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getExpPt() {
        return expPt;
    }

    public void setExpPt(int expPt) {
        this.expPt = expPt; 
    }
}
